<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	if(session.getAttribute("loginUser") == null){
		request.setAttribute("message","您没有登录");
		request.getRequestDispatcher("../framework/login.jsp").forward(request, response);
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
	<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
	<meta HTTP-EQUIV="Expires" CONTENT="0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SHHIC生产线测试平台后台管理系统</title>
<script type="text/javascript" src="../dojo-release-1.5.0/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
<style type="text/css">
	@import "../dojo-release-1.5.0/dijit/themes/tundra/tundra.css";
	@import "../dojo-release-1.5.0/dojo/resources/dojo.css";
</style>
<script type="text/javascript">
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.BorderContainer");

dojo.require("dijit.layout.AccordionContainer");
dojo.require("dijit.layout.AccordionPane");

dojo.require("dojo.window");
dojo.require("dojo._base.query");

dojo.require("dijit.Dialog");
dojo.require("dijit.form.Form");
dojo.require("dijit.form.ValidationTextBox");

</script>
<jsp:include page="../templates/appInfo.jsp"/>
<script type="text/javascript">
//窗口大小变化时，重新布局
function resizeFramework(){
	dojo.style("framework","height",dojo.window.getBox().h+"px");
	dojo.style("naviContainer","height",(dojo.window.getBox().h-150)+"px");
	dojo.style("navigateMenu","height",(dojo.window.getBox().h-140)+"px");

	dijit.byId("framework").resize();
}

//初始化框架界面
function initFrameworkUI(){
	dojo.place("appTitle","titleBar");
	dojo.place("bottomInfo","bottomBar");
	dojo.place("navigateMenu","navigateBar");

	dojo.query("a").forEach(function(item){
		dojo.attr(item,"target","contentFrame");
	});
	
	omitNoPrivilegedMenus();
}
//移除无权限的菜单项
function omitNoPrivilegedMenus(){
	dojo.destroy(nopri);
}

dojo.addOnLoad(function(){
	initFrameworkUI();
	dojo.connect(window,"resize",resizeFramework);	

	resizeFramework();
		
	
	setInterval(checkLoginFun,10000);
});

function checkLoginFun(){
	//周期检查是否登录的方法
	dojo.xhrGet({
		 url:"heartbeat.do",
		 encoding : 'UTF-8',
		 handleAs:"text",
		 preventCache:true,
		 load:function(response){
			 if(response == 'nologin'){
				dojo.byId("messageDlg").innerHTML="您没有登录或登录超时，请<a href='bkgrdLogout.do'>重新登录</a>！";
				dijit.byId("messageDlg").show();
			 }
		 },
		 error:function(error){
			dojo.byId("messageDlg").innerHTML="网络异常！";
			dijit.byId("messageDlg").show();
		 }
	});
}

function modifyPassword(){
	dijit.byId('modifyPasswordDlg').show();
}

function submitPassword(){
	if(!dijit.byId('psdFrm').isValid()){
		return;
	}
	if(dijit.byId('newPassword').value != dijit.byId('reNewPassword').value){
		alert('两次密码应相同');
		return;
	}
	dojo.xhrPost({
		 url:"modifyPassword.do",
		 encoding : 'UTF-8',
		 content:{newPassword:dijit.byId('newPassword').value,oldPassword:dijit.byId('oldPassword').value},
		 handleAs:"json",
		 load:function(response){
			 alert(response.message);
			 if(response.rtnCode == 0){
				 dijit.byId('oldPassword').reset();
				 dijit.byId('newPassword').reset();
				 dijit.byId('reNewPassword').reset();
				dijit.byId('modifyPasswordDlg').hide();
			 }
		 }
	});
	
	
	
}
</script>
</head>
<body class="tundra">
<div dojoType="dijit.layout.BorderContainer" style="width:100%;height:600px" design="headbar" liveSizing="true" id="framework">
	<div id="titleBar" dojoType="dijit.layout.ContentPane" region="top" style="height:45px;">
	</div>
	<div id="navigateBar" dojoType="dijit.layout.ContentPane" region="left" style="width:155px;overflow: visible;" splitter="true">
	
	</div>
	<div id="bottomBar" dojoType="dijit.layout.ContentPane" region="bottom" style="height:20px;">
	</div>
	<div dojoType="dijit.layout.ContentPane" region="center">
		<iframe id="contentFrame" name="contentFrame" src="about:blank" frameborder="0" style="width: 100%;height: 100%"></iframe>
	</div>
</div>

<div>
</div>

<div id="messageDlg" dojoType="dijit.Dialog" title="消息" style="font-size: 14px; height: 100px;width: 300px;text-align: center; vertical-align: middle;">
</div>


<div id="modifyPasswordDlg" dojoType="dijit.Dialog" title="修改密码" style="font-size: 14px;text-align: center; vertical-align: middle;">
	<form dojoType='dijit.form.Form' id="psdFrm">
	<table>
		<tr><td>请输入原密码</td><td><input dojoType="dijit.form.ValidationTextBox" required="true" type="password" id='oldPassword'/> </td></tr>
		<tr><td>请输入新密码</td><td><input dojoType="dijit.form.ValidationTextBox" required="true" type="password" id="newPassword"/></td></tr>
		<tr><td>再次输入新密码</td><td><input dojoType="dijit.form.ValidationTextBox" required="true" type="password" id="reNewPassword"/></td></tr>
		<tr><td colspan="2">
			<button dojoType="dijit.form.Button" onclick='submitPassword()'>确认修改</button>
		</td></tr>
	</table>
	</form>
</div>
</body>
</html>